<template>
  <div class="tabBar">
    <!-- 页面组件 -->
    <Coin v-if="activeTab == 0" :isShowNavBar="false"></Coin>
    <Activity v-else-if="activeTab == 1" :isShowNavBar="false"></Activity>
    <Mining v-else-if="activeTab == 2" :isShowNavBar="false"></Mining>
    <Pledge v-else-if="activeTab == 3" :isShowNavBar="false"></Pledge>
    <AssetDetail v-else-if="activeTab == 4" :isShowNavBar="false"></AssetDetail>
  </div>
</template>
<script setup name="tabBar">
import { useEventBus } from "@vueuse/core";
import Coin from "../mvp/coin/coin.vue";
import Mining from "../mvp/mining/index.vue";
import AssetDetail from "../mvp/assetDetails/index.vue";
import Activity from "../activity/index.vue";
import Pledge from "../pledge/index.vue";
// import { navigateBack, getOssFileUrl } from "@/utils";
// import { navigateI18nTo } from "@/utils";
import { useGlobalStore } from "~~/store/global";

definePageMeta({
  // keepalive: true,
  layout: "tab-bar",
});
const globalStore = useGlobalStore();
const { t } = useI18n();
const route = useRoute();
console.log("tabbar 页面参数:", route.query);
const activeTab = ref(0); // 当前激活的 tab 页面
if (globalStore.$state.tabBarIdx >= 0) {
  activeTab.value =globalStore.$state.tabBarIdx;
}
// 接收tab 切换通知
const tabBarEmit = useEventBus("tab-bar-jump-emit");
tabBarEmit.on((idx) => {
  activeTab.value = idx;
  // console.log("点击了 tabBar:", activeTab.value);
});

// firebase埋点
const firebase = useInitFirebase(); // 初始化firebase

onMounted(() => {
  // 1. 埋点
  firebase?.logEvent("BDC_H5_Tab_PUV");
});
</script>
<style lang="scss" scoped>
.tabBar {
  position: relative;
  background-color: #f4f5f7;
  margin-bottom: constant(safe-area-inset-bottom);
  margin-bottom: env(safe-area-inset-bottom);
  padding-bottom: constant(safe-area-inset-bottom);
  padding-bottom: env(safe-area-inset-bottom);
}
</style>
